class SleepDetail {
  final int? id;
  final String? type;
  final int? score;
  final String deviceSn;
  final String startDate;
  final String endDate;
  final int sleepTime;
  final double sleepEfficiency;
  final String dailyValue;
  final int deepTime;
  final int lightTime;
  final int awakeTime;
  final int remTime;
  final List<int> rawBytes;
  final int totalTime;
  final String state;
  final String sleepChronotype;
  final String highConfidence;
  final int bedtime;
  final List<SleepDetailItem> details;

  SleepDetail({
    this.id,
    this.type,
    this.score,
    required this.deviceSn,
    required this.startDate,
    required this.endDate,
    required this.sleepTime,
    required this.sleepEfficiency,
    required this.dailyValue,
    required this.deepTime,
    required this.lightTime,
    required this.awakeTime,
    required this.remTime,
    required this.rawBytes,
    required this.totalTime,
    required this.state,
    required this.sleepChronotype,
    required this.highConfidence,
    required this.bedtime,
    required this.details,
  });

  Map<String, dynamic> toJson() => {
    'id': id,
    'type': type,
    'score': score,
    'deviceSn': deviceSn,
    'startDate': startDate,
    'endDate': endDate,
    'sleepTime': sleepTime,
    'sleepEfficiency': sleepEfficiency,
    'dailyValue': dailyValue,
    'deepTime': deepTime,
    'lightTime': lightTime,
    'awakeTime': awakeTime,
    'remTime': remTime,
    'rawBytes': rawBytes,
    'totalTime': totalTime,
    'state': state,
    'sleepChronotype': sleepChronotype,
    'highConfidence': highConfidence,
    'bedtime': bedtime,
    'details': details.map((e) => e.toJson()).toList(),
  };
}

class SleepDetailItem {
  final int type;
  final int startTime;
  final int endTime;
  final int totalTime;

  SleepDetailItem({
    required this.type,
    required this.startTime,
    required this.endTime,
    required this.totalTime,
  });

  Map<String, dynamic> toJson() => {
    'type': type,
    'startTime': startTime,
    'endTime': endTime,
    'totalTime': totalTime,
  };
}